﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement.Handlers;
using Downplay.Mechanics.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;

namespace Downplay.Science.Tests.Mechanics {

    /// <summary>
    /// Using this to nail down exactly when various events are handled
    /// </summary>
    public class StubSocketHandler : ContentHandler {

        public List<StubSocketHandlerData> SocketsCreated = new List<StubSocketHandlerData>();
        public List<StubSocketHandlerData> SocketsPublished = new List<StubSocketHandlerData>();
        public List<StubSocketHandlerData> SocketsUpdated = new List<StubSocketHandlerData>();
        public List<Tuple<StubSocketHandlerData>> SocketsVersioned = new List<Tuple<StubSocketHandlerData>>();

        public List<StubSocketHandlerData> ConnectorsCreated = new List<StubSocketHandlerData>();
        public List<StubSocketHandlerData> ConnectorsPublished = new List<StubSocketHandlerData>();
        public List<StubSocketHandlerData> ConnectorsUpdated = new List<StubSocketHandlerData>();
        public List<Tuple<StubSocketHandlerData,StubSocketHandlerData>> ConnectorsVersioned = new List<Tuple<StubSocketHandlerData,StubSocketHandlerData>>();

        public void Clear() {
            SocketsCreated.Clear();
            SocketsPublished.Clear();
            SocketsUpdated.Clear();
            SocketsVersioned.Clear();
            ConnectorsCreated.Clear();
            ConnectorsPublished.Clear();
            ConnectorsUpdated.Clear();
            ConnectorsVersioned.Clear();
        }

        public StubSocketHandler() {

            OnCreated<SocketsPart>((context, part) => {
                Add(SocketsCreated, part);
            });
            OnPublishing<SocketsPart>((published, part) => {
                Add(SocketsPublished, part);
            });

        }

        private void Add(List<StubSocketHandlerData> SocketsCreated, SocketsPart part) {
            throw new NotImplementedException();
        }

    }

    public class StubSocketHandlerData {

        public IContent Part { get; set; }
        public int Id { get; set; }
        public int VersionId { get; set; }
        public ContentItemVersionRecord VersionRecord { get; set; }
    }
}
